package com.wanxi.user.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
@Slf4j
public class RabbitConfig {

    @Bean
    public Queue adminQueue(){
        log.info("看这里的信息: {}","adminQueue 实例化成功。。。");
        return new Queue("admin",true);
    }

    @Bean
    TopicExchange emailTopicExchange(){
        log.info("看这里的信息: {}","emailTopicExchange 实例化成功。。。");
        return new TopicExchange("email.topic",true,false);
    }


    @Bean
    Binding adminQueue2EmailTopic(){
        log.info("看这里的信息: {}","admin 绑定到 emailTopic");
        return BindingBuilder.bind(adminQueue()).to(emailTopicExchange()).with("email.#");
    }


}
